<template>
  <section>
    <h2>子组件</h2>
    <p>父传来的name: {{ name }}</p>
    <p>父传来的age: {{ age }}</p>
    <input v-model="name">
  </section>
</template>

<script lang="ts">
import { watch } from "vue";

export default {
  props: {
    name: {
      type: String,
    },
    age: {
      type: String,
    },
  },
  // setup的第一个参数：props，父传子的参数
  setup(props:any) {
    watch(
      () => props.name,
      (newVal) => {
        console.log("我的name变化了：", newVal);
      }
    );
  },
};
</script>

<style>
</style>